home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3849 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP!! BAMBOOZLED BEGINNER!!
  5. Date: 31 Jan 1996 07:46 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <31JAN199607463619@erich.triumf.ca>
  9. References: <Pine.OSF.3.91l.960130235948.20497A-100000@saul3.u.washington.edu>
  10. NNTP-Posting-Host: erich.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <Pine.OSF.3.91l.960130235948.20497A-100000@saul3.u.washington.edu>, Ramon Mariano Jr <rmariano@u.washington.edu> writes...
  14. >Hello everybody!
  15. >I'm a beginning C-programmer and for the past couple of days, I've been
  16. >totally stuck in my program. The purpose of my program is to ask the user
  17. >for an integer 'i' and raise it by a power 'n'. I've been succesful in
  18. >computing 5 to the 6th power, 3 to the 4th power, and other small-sized
  19. >equations. However, when I try to raise 5 to the 7th power, I get "12589" 
  20. >when it really should be "78125". My teacher told me that instead of using
  21. >plain 'int', I should use 'long int'. I tried that, but it's still not
  22. >working. If anyone can help me out here, I'd GREATLY appreciate it! I've
  23. >included my code below... (by the way, I'm not allowed to use the <math.h>
  24. >library)
  25.  
  26. If you are working in MS-DOS, an int on most compilers is 16 bits, which gives
  27. a range of -32768 to 32767.  A long int is 32 bits, which will have a range of
  28. about +/- 2 billion.
  29.  
  30. To print a long int, you need to use "%ld" instead of "%d" in printf().
  31.  
  32. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  33. Internet: bennett@triumf.ca         | of one another only when one can be
  34. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  35. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  36. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.